//
//  UIButton+YQUIButton.m
//  WeiboOC
//
//  Created by yang on 15/11/15.
//  Copyright © 2015年 yang. All rights reserved.
//

#import "UIButton+YQUIButton.h"

@implementation UIButton (YQUIButton)
- (UIButton*)initWithTitle:(NSString*)title backImage:(NSString*)backImage color:(UIColor*)color image:(NSString*)image size:(CGFloat)size
{
    UIButton* btn = [[UIButton alloc] init];
    [btn setTitle:title forState:UIControlStateNormal];
    if (backImage != nil) {
        [btn setBackgroundImage:[UIImage imageNamed:backImage] forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted", backImage]] forState:UIControlStateHighlighted];
    }
    if (size != 0) {
        btn.titleLabel.font = [UIFont systemFontOfSize:size];
    }else{
        btn.titleLabel.font = [UIFont systemFontOfSize:14];
    }
    if (image != nil) {
        [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    }
    if (color != nil) {
        
        [btn setTitleColor:color forState:UIControlStateNormal];
    }
    return btn;
}
@end
